home *** CD-ROM | disk | FTP | other *** search
- /*
- * CBLibrary - RoundRobin
- * Copyright (C) 2003 Chris Bazley
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- /* Round-robin system for multiple threads that require null polls */
-
- #ifndef RoundRobin_h
- #define RoundRobin_h
-
- #include <stdbool.h>
- #include "kernel.h"
-
- /*
- A RoundRobinHandler function must return when the volatile bool
- pointed to by *time_up goes 'true'. A RoundRobinHandler may
- return early (thus relinquishing control to the next thread)
- but if it does so consistently then it will receive less CPU time
- overall than other threads.
- */
-
- typedef void (RoundRobinHandler) (void *handle,
- const volatile bool *time_up);
-
- /*
- The time value (in centisenconds) is the MINIMUM amount of work that
- we do per null event received from the Wimp. The actual granularity
- cannot be enforced - it is the responsibility of each
- RoundRobinHandler to return when the word pointed to by *time_up is
- set (or before this).
- */
-
- extern _kernel_oserror *RoundRobin_initialise(unsigned int time);
-
- extern _kernel_oserror *RoundRobin_finalise(void);
-
- /* Register thread */
- extern _kernel_oserror *RoundRobin_register(RoundRobinHandler *handler, void *handle);
-
- /* Deregister thread */
- extern void RoundRobin_deregister(RoundRobinHandler *handler, void *handle);
-
- /* Suspend ALL threads */
- extern void RoundRobin_suspend(void);
-
- /* Resume ALL threads */
- extern void RoundRobin_resume(void);
-
- #endif
-